﻿@model DTcms.Model.BaseModel
@{
    ViewBag.Title = "收货地址-" + Model.site.name;
    string templateskin = Model.templateskin;
}
@section HeaderContent{

}
<!--当前位置-->
<div class="section">
    <div class="location">
        <span>当前位置：</span>
        <a href="@Html.linkurl("index")">首页</a> &gt;
        <a href="@Html.linkurl("usercenter","index")">会员中心</a>&gt;
        <a href="@Html.linkurl("useraddress")">收货地址</a>
    </div>
</div>
<!--/当前位置-->

<div class="section clearfix">
    <!--页面左边-->
    @Html.Partial("_ucenter_nav")
    <!--/页面左边-->
    <!--页面左边-->
    <div class="right-auto">
        <div class="bg-wrap" style="min-height:765px;">
            <!--收货地址列表-->
            <div class="sub-tit">
                <a class="add" href="@Html.linkurl("useraddress_edit","add")"><i class="iconfont icon-plus"></i>新增地址</a>
                <ul>
                    <li class="selected">
                        <a href="@Html.linkurl("useraddress")">收货地址</a>
                    </li>
                </ul>
            </div>

            <div class="table-wrap">
                <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                    <thead>
                        <tr>
                            <th lay-data="{checkbox:true}"></th>
                            <th lay-data="{field:'name',templet:'#address'}">收货地址</th>
                            <th lay-data="{field:'mobile'}">手机</th>
                            <th lay-data="{field:'email'}">邮箱</th>
                            <th lay-data="{templet: '#barDemo'}">操作</th>
                        </tr>
                    </thead>
                </table>
            </div>
            <input id="turl" type="hidden" value="@Html.linkurl("useraddress")" /><!--存在跳转的URL值-->
            <!--/收货地址列表-->
        </div>
    </div>
    <!--/页面左边-->
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-xs" href="/user/address/edit-{{d.id}}.html">编辑</a> |
    {{#  if(d.is_default==0){ }}
    <a onclick="clickSubmit('/api/submit_ajax/user_address_default?id={{d.id}}')" href="javascript:;">设为默认</a>
    {{#  } else { }}
    已默认
    {{#  } }} 
</script>
<script type="text/html" id="address">
    {{d.accept_name}} {{d.area}} {{d.address}}
</script>
@section Scripts{
    <script type="text/javascript">
        layui.use(['table', 'myaspx'], function () {
            var table = layui.table, os = layui.myaspx;
            // 渲染表格
            os.dataBind('/api/lisence_ajax/get_addr_book_list');

            //监听行工具事件
            table.on('tool(ltable)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('确认操作吗？', function (index) {
                        cmswh.request("user_address_delete", "POST", { checkId: data.id });
                        obj.del();
                        layer.close(index);
                    });
                } 
            });
        });
    </script>
}